# _*_ coding:utf-8 _*_
"""
:File: config.py
:Author: cfp
:Date: 2025/9/10 09:32
:LastEditTime: 2025/9/10 09:32
:LastEditors: cfp
:Description: 
"""
import os
from dotenv import load_dotenv

load_dotenv()


class Config:
    # PostgreSQL 配置
    DB_HOST = os.getenv('DB_HOST', 'localhost')
    DB_PORT = os.getenv('DB_PORT', '5432')
    DB_NAME = os.getenv('DB_NAME', 'fireegg')
    DB_USER = os.getenv('DB_USER', 'fireegg')
    DB_PASSWORD = os.getenv('DB_PASSWORD', 'fireegg')

    # Redis 配置
    REDIS_HOST = os.getenv('REDIS_HOST', 'localhost')
    REDIS_PORT = os.getenv('REDIS_PORT', '6379')
    REDIS_DB = os.getenv('REDIS_DB', 0)

    # 爬虫配置
    MAX_WORKERS = 2
    REQUEST_DELAY = 2

    @property
    def database_url(self):
        return f"postgresql://{self.DB_USER}:{self.DB_PASSWORD}@{self.DB_HOST}:{self.DB_PORT}/{self.DB_NAME}"